package com.mago.tis.daoImpl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.mago.tis.dao.ILoginDao;
import com.mago.tis.utility.QueryConstant;

public class LoginDao extends BaseDao implements ILoginDao {

	/**
	 * Method to check whether user is authenticated
	 * @param name
	 * @param password
	 * @return
	 */
	public boolean checkAuthentication(String name, String password) {

		// Prepare the parameters
		List lParamList = new ArrayList();
		lParamList.add(0, name);
		lParamList.add(1, password);

		// Get the query by passing parameters
		String query = getQuery(QueryConstant.CHECK_AUTHENTICATION, lParamList);
		ResultSet rs = null;
		try {
			rs = getResults(query);
			if (rs != null && rs.next() != false) {
				System.out.println("ID"+rs.getInt("USER_LOGIN_ID"));
				return true;
			} else
				return false;

		} catch (SQLException sqe) {
			return false;
		}
	}
}
